REM 让脚本暂停10秒
ping -n 10 127.0.0.1 >nul

REM 显示windows系统中的网卡：

netsh interface ipv4 show interfaces

REM powershelll启用有线网卡转发：





REM 注册表中启用转发：

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v IPEnableRouter /t REG_DWORD /d 1 /f

@echo off
setlocal EnableDelayedExpansion

set adapterName=vEthernet (WSL)
set found=0

:checkAdapter
for /f "delims=" %%i in ('netsh interface ipv4 show interfaces ^| findstr /i /c:"!adapterName!"') do set found=1

if !found! equ 0 (
    echo Adapter !adapterName! not found, waiting...
    ping -n 5 127.0.0.1 >nul
    goto checkAdapter
) else (
    echo Adapter !adapterName! found, enabling forwarding.
)
REM powershell启用wsl连接的虚拟网卡转发：
netsh interface ipv4 set int "!adapterName!" forwarding=enabled

endlocal




net start sharedaccess

net stop sharedaccess